package com.rookie.tool.module.controller;

import com.rookie.tool.module.example.excel.Person;
import com.rookie.tool.module.example.excel.TestExcelDataHandle;
import com.rookie.tool.module.util.excel.ExcelProcessUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author rookie
 */
@RestController
public class TestController {

    @Autowired
    private TestExcelDataHandle testExcelDataHandle;

    @PostMapping("upload")
    public void upload(@RequestParam(value = "file") MultipartFile file) throws IOException {
        ExcelProcessUtils.readAllSheet(file.getInputStream(), Person.class, testExcelDataHandle);
    }
}
